package com.hyh.shipment.service.impl;

import cn.hutool.http.HttpStatus;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hyh.shipment.result.PageResult;
import com.hyh.shipment.dao.ShipmenMapper;
import com.hyh.shipment.domain.Shipment;
import com.hyh.shipment.service.ShipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ShipmentServiceImpl implements ShipmentService {

    @Autowired
    private ShipmenMapper shipmenMapper;
    @Override
    public PageResult updateShipment(Integer orderNumber) {
        LambdaQueryWrapper<Shipment> qw = new LambdaQueryWrapper<>();
        qw.eq(Shipment::getOrderNumber,orderNumber);
        Shipment shipment = shipmenMapper.selectById(qw);
        shipment.setStatus("1");
        shipmenMapper.updateById(shipment);
        return new PageResult(HttpStatus.HTTP_OK,null,"发货成功");
    }

    @Override
    public PageResult confirmReceipt(Integer orderNumber) {
        LambdaQueryWrapper<Shipment> qw = new LambdaQueryWrapper<>();
        qw.eq(Shipment::getOrderNumber,orderNumber);
        Shipment shipment = shipmenMapper.selectById(qw);
        shipmenMapper.updateById(shipment);
        return new PageResult(HttpStatus.HTTP_OK,null,"确认成功");
    }
}
